﻿using System.Net;
using System.Text;
using System.Web.Mvc;
using SDCloudSolution.SDCloud.Web.Infrastructure.Interfaces;

namespace SDCloudSolution.SDCloud.Web.Infrastructure
{
    public class TextProcessor : ITextProcessor
    {
        public MvcHtmlString ProcessText(string userInputFormattedText)
        {
            var stringBuilder = new StringBuilder();

            var lines = userInputFormattedText.Split('\n');
            foreach (var line in lines)
            {
                stringBuilder.AppendLine(WebUtility.HtmlEncode(line));
                stringBuilder.AppendLine("<br/>");
            }

            return new MvcHtmlString(stringBuilder.ToString());
        }
    }
}